Sub Main ()
with metascript 
   .showform "Select 0 as s, Code, Name, BillNo, BillDate , Payrupees, error, salekey from salehead , customer , GIRN_Out " & _
      " where customerkey = customerid and billno=DocNo and MyStatus=0 and billdate between '" & local.dtfrom.tag & "' and '" & local.dtto.tag & "'" & _
      " and GetIRN=1 ", .getdatafile, s1, s2
   
   if trim(s1)<>"" then 
      
      
      st = "delete from girn_inp where docno in "
      st = st & " (select billno " & _
         " from salehead where salekey in (" & s1 & "))" 
      
      .exec st & " " , .getdatafile
      
      st = "delete from girn_OUT where irn='' and docno in "
      st = st & " (select billno " & _
         " from salehead where salekey in (" & s1 & "))" 
      
      .exec st & " " , .getdatafile
      
      
      st = "update salehead set getirn=0 where salekey in (" & s1 & ") "
      
      .exec st & " " , .getdatafile
      
      
      msgbox "Bills Selected " & bills & " Added " & added & vbcrlf & " Done",vbinformation,"PharmaPulse"
   else
      msgbox "Operation cancelled by user"
   end if
   
   
end with 
End Sub







